{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "def func(x, y):\n",
    "    return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "grid_x, grid_y = np.mgrid[0:1:200j, 0:1:200j]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.13812209 0.5790329 ]\n",
      " [0.81357383 0.66212921]\n",
      " [0.05709874 0.92177028]\n",
      " ...\n",
      " [0.39529144 0.17176101]\n",
      " [0.75430401 0.14559935]\n",
      " [0.4688269  0.48296882]]\n"
     ]
    }
   ],
   "source": [
    "rng = np.random.default_rng()\n",
    "points = rng.random((1000, 2))\n",
    "print(points)\n",
    "values = func(points[:,0], points[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.interpolate import griddata\n",
    "grid_z0 = griddata(points, values, (grid_x, grid_y), method='nearest')\n",
    "grid_z1 = griddata(points, values, (grid_x, grid_y), method='linear')\n",
    "grid_z2 = griddata(points, values, (grid_x, grid_y), method='cubic')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dsp",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.15"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "7126be7c7525f67bfd7d50d57ac01c12586c7dfc012162c22e3b0465c2c9f0f0"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
